import UnoCSS from "unocss/vite";
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
import { resolve } from "path";
import svgLoader from "vite-svg-loader"; // svg加载器

/**
 * unplugin-auto-import -> 自动导入 API，无需手动编写 import 语句
 * 例如
 * import { ref } from 'vue' -> 可以直接使用 ref()
 * import { useDialog } from 'naive-ui' -> 可以直接使用 useDialog()
 *
 *
 * unplugin-vue-components -> 自动导入组件，无需手动编写 import 语句
 * 例如
 * <n-button>按钮</n-button> -> 可以直接使用 n-button 组件
 * unplugin-vue-components
 */
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { NaiveUiResolver } from "unplugin-vue-components/resolvers";

export default defineConfig({
    plugins: [
        vue(),
        UnoCSS(),
        svgLoader(),
        AutoImport({
            imports: [
                "vue",
                {
                    "naive-ui": [
                        "useDialog",
                        "useMessage",
                        "useNotification",
                        "useLoadingBar",
                    ],
                },
            ],
        }),
        Components({
            resolvers: [NaiveUiResolver()],
        }),
    ],
    resolve: {
        alias: {
            "@": resolve(__dirname, "src"),
        },
    },
    server: {
        port: 14972,
    },
});
